package com.example.application;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.example.application.R;

public class News_Main extends Activity {
    private WebView mwebView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_news);
        mwebView = findViewById(R.id.webview);
        WebSettings settings = mwebView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setDomStorageEnabled(true);
        settings.setAllowFileAccess(true);
        settings.setAppCacheEnabled(true);
        settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);


        mwebView.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                //mwebView.loadUrl("javascript:function hide(){document.getElementByClassName(\"bannerclickable\")[0].style.display=\"none\";}hide();");
            }
        });
        mwebView.loadUrl("https://m.tianqi.com/news/");//https://m.tianqi.com/news/

    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if(mwebView.canGoBack()){
            mwebView.goBack();
            return false;
        }
        else{
            return super.onKeyDown(keyCode,event);
        }
    }
}